home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-01-19 | 51.6 KB | 1,614 lines |
- Newsgroups: comp.sources.misc
- subject: v10i016: PCcurses v.1.4 part 2 of 7
- from: bl@infovox.se (Bj|rn Larsson)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 10, Issue 16
- Submitted-by: bl@infovox.se (Bj|rn Larsson)
- Archive-name: pccurses14/part02
-
- # ----------------------------- cut here -----------------------------
- #! /bin/sh
- # This is a shell archive. Remove anything before the `cut' line,
- # then unpack by saving it into a file and typing `sh file'. The
- # archive ends by exit(0), so don't worry about trailing junk.
- #
- # (This is archive 2 in a series of 7).
- #
- # Contents:
- #
- # attrib.c
- # border.c
- # boxes.c
- # chardel.c
- # clrtobot.c
- # clrtoeol.c
- # curspriv.h
- # linedel.c
- # lineins.c
- # options.c
- # refresh.c
- # setmode.c
- # setterm.c
- #
- # Wrapped by USER@MS-DOS --- Sun Jan 14 14:02:26 1990
- #
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f attrib.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"attrib.c\"
- else
- echo Extracting - \"attrib.c\"
- sed "s/^X//" >attrib.c <<'END_OF_attrib.c'
- X/****************************************************************/
- X/* Character attribute routines of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Portability improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Rcsid[] string for maintenance: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_attrib_rcsid[] = "@(#)attrib.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wattrset() sets the attributes as specified in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wattrset(win,attrs)
- X WINDOW *win;
- X int attrs;
- X {
- X win->_attrs = attrs & ATR_MSK;
- X } /* wattrset */
- X
- X/****************************************************************/
- X/* Wattron() sets the specified attribute(s) in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wattron(win,attrs)
- X WINDOW *win;
- X int attrs;
- X {
- X win->_attrs |= (attrs & ATR_MSK);
- X } /* wattron */
- X
- X/****************************************************************/
- X/* Wattroff() clears the specified attribute(s) in window */
- X/* 'win'. */
- X/****************************************************************/
- X
- Xvoid wattroff(win,attrs)
- X WINDOW *win;
- X int attrs;
- X {
- X win->_attrs &= (~attrs & ATR_MSK);
- X } /* wattroff */
- X
- X/****************************************************************/
- X/* Wstandout() starts standout mode in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wstandout(win)
- X WINDOW *win;
- X {
- X win->_attrs = A_STANDOUT;
- X } /* wstandout */
- X
- X/****************************************************************/
- X/* Wstandend() clears all special attributes in window 'win'. */
- X/****************************************************************/
- X
- Xvoid wstandend(win)
- X WINDOW *win;
- X {
- X win->_attrs = ATR_NRM;
- X } /* wstandend */
- X
- X/****************************************************************/
- X/* Attrset() sets the attributes as specified in stdscr. */
- X/****************************************************************/
- X
- Xvoid attrset(attrs)
- X int attrs;
- X {
- X stdscr->_attrs = attrs & ATR_MSK;
- X } /* attrset */
- X
- X/****************************************************************/
- X/* Attron() sets the specified attribute(s) in stdscr. */
- X/****************************************************************/
- X
- Xvoid attron(attrs)
- X int attrs;
- X {
- X stdscr->_attrs |= (attrs & ATR_MSK);
- X } /* attron */
- X
- X/****************************************************************/
- X/* Attroff() clears the specified attribute(s) in stdscr. */
- X/****************************************************************/
- X
- Xvoid attroff(attrs)
- X int attrs;
- X {
- X stdscr->_attrs &= (~attrs & ATR_MSK);
- X } /* attroff */
- X
- X/****************************************************************/
- X/* Standout() starts standout mode in stdscr. */
- X/****************************************************************/
- X
- Xvoid standout()
- X {
- X stdscr->_attrs = A_STANDOUT;
- X } /* standout */
- X
- X/****************************************************************/
- X/* Standend() clears all special attributes in stdscr. */
- X/****************************************************************/
- X
- Xvoid standend()
- X {
- X stdscr->_attrs = ATR_NRM;
- X } /* standend */
- END_OF_attrib.c
- if test 3851 -ne `wc -c <attrib.c`; then
- echo \"attrib.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f border.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"border.c\"
- else
- echo Extracting - \"border.c\"
- sed "s/^X//" >border.c <<'END_OF_border.c'
- X/****************************************************************/
- X/* Box border control routines of the PCcurses package. */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4 : Changed to draw a border. Use short wherever */
- X/* possible: Portability improvements: 900114 */
- X/* 1.3: Released: 881005 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_border_rcsid[] = "@(#)border.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wborder(win, l, r, t, b, tl, tr, bl, br) draws a border in */
- X/* window win, with the specified characters as border edges: */
- X/* l left */
- X/* r right */
- X/* b bottom */
- X/* t top */
- X/* tl top left corner */
- X/* tr top right corner */
- X/* bl bottom left corner */
- X/* br bottom right corner */
- X/****************************************************************/
- X
- Xvoid wborder(win, l, r, t, b, tl, tr, bl, br)
- X WINDOW *win;
- X int l;
- X int r;
- X int t;
- X int b;
- X int tl;
- X int tr;
- X int bl;
- X int br;
- X {
- X short xmax, ymax, i;
- X
- X ymax = win->_maxy - 1;
- X xmax = win->_maxx - 1;
- X for (i = 1; i <= xmax-1;i++)
- X {
- X win->_line[0][i] = t | win->_attrs;
- X win->_line[ymax][i] = b | win->_attrs;
- X } /* for */
- X for (i = 1;i <= ymax-1;i++)
- X {
- X win->_line[i][0] = l | win->_attrs;
- X win->_line[i][xmax] = r | win->_attrs;
- X } /* for */
- X win->_line[0][0] = tl | win->_attrs;
- X win->_line[0][xmax] = tr | win->_attrs;
- X win->_line[ymax][0] = bl | win->_attrs;
- X win->_line[ymax][xmax] = br | win->_attrs;
- X
- X for (i=0; i <= ymax ; i++)
- X {
- X win->_minchng[i] = 0;
- X win->_maxchng[i] = xmax;
- X } /* for */
- X } /* wborder */
- X
- X/****************************************************************/
- X/* Border(l, r, t, b, tl, tr, bl, br) draws a border in stdscr, */
- X/* with the specified characters as border edges: */
- X/* l left */
- X/* r right */
- X/* b bottom */
- X/* t top */
- X/* tl top left corner */
- X/* tr top right corner */
- X/* bl bottom left corner */
- X/* br bottom right corner */
- X/* Don't make this a call to wborder() - it would require soo */
- X/* much stack for parameters... */
- X/****************************************************************/
- X
- Xvoid border(l, r, t, b, tl, tr, bl, br)
- X int l;
- X int r;
- X int t;
- X int b;
- X int tl;
- X int tr;
- X int bl;
- X int br;
- X {
- X short xmax, ymax, i;
- X
- X ymax = stdscr->_maxy - 1;
- X xmax = stdscr->_maxx - 1;
- X for (i = 1; i <= xmax-1;i++)
- X {
- X stdscr->_line[0][i] = t | stdscr->_attrs;
- X stdscr->_line[ymax][i] = b | stdscr->_attrs;
- X } /* for */
- X for (i = 1;i <= ymax-1;i++)
- X {
- X stdscr->_line[i][0] = l | stdscr->_attrs;
- X stdscr->_line[i][xmax] = r | stdscr->_attrs;
- X } /* for */
- X stdscr->_line[0][0] = tl | stdscr->_attrs;
- X stdscr->_line[0][xmax] = tr | stdscr->_attrs;
- X stdscr->_line[ymax][0] = bl | stdscr->_attrs;
- X stdscr->_line[ymax][xmax] = br | stdscr->_attrs;
- X
- X for (i=0; i <= ymax ; i++)
- X {
- X stdscr->_minchng[i] = 0;
- X stdscr->_maxchng[i] = xmax;
- X } /* for */
- X } /* border */
- END_OF_border.c
- if test 3600 -ne `wc -c <border.c`; then
- echo \"border.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f boxes.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"boxes.c\"
- else
- echo Extracting - \"boxes.c\"
- sed "s/^X//" >boxes.c <<'END_OF_boxes.c'
- X/****************************************************************/
- X/* Box() routines of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: References to win->borderchar[] removed due to */
- X/* re-defined border() functions. Use of short */
- X/* wherever possible. Portability improvements: 900114 */
- X/* 1.3: MSC '-W3', Turbo'C' '-w -w-pro' checks. */
- X/* Support for border(), wborder() functions: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_boxes_rcsid[] = "@(#)boxes.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* wbox(win,ymin,xmin,ymax,xmax,v,h) draws a box in window */
- X/* 'win', enclosing the area xmin-xmax and ymin-xmax. If */
- X/* xmax and/or ymax is 0, the window max value is used. 'v' and */
- X/* 'h' are the vertical and horizontal characters to use. If */
- X/* 'v' and 'h' are PC grapics lines, wbox will make the corners */
- X/* in a pretty way. */
- X/****************************************************************/
- X
- Xint wbox(win,ymin,xmin,ymax,xmax,v,h)
- X WINDOW *win;
- X int ymin;
- X int xmin;
- X int ymax;
- X int xmax;
- X char v;
- X char h;
- X {
- X static short l, r, t, b, tl, tr, bl,br; /* border chars */
- X short i;
- X
- X if (ymax == 0)
- X ymax = win->_maxy - 1;
- X if (xmax == 0)
- X xmax = win->_maxx - 1;
- X
- X if (ymin >= win->_maxy || ymax > win->_maxy ||
- X xmin >= win->_maxx || xmax > win->_maxx ||
- X ymin >= ymax || xmin >= xmax
- X )
- X return(ERR);
- X
- X l = r = v & 0xff; /* get rid of sign-extended int */
- X t = b = h & 0xff;
- X tl = tr = bl = br = v; /* default same as vertical */
- X
- X if (l == 0xba) /* vertical double bars */
- X {
- X if (t == 0xcd) /* horizontal too? */
- X {tl=0xc9;tr=0xbb;bl=0xc8;br=0xbc;}/* use double bar corners */
- X else
- X {tl=0xd6;tr=0xb7;bl=0xd3;br=0xbd;}/* use hor-s vert-d corners */
- X } /* if */
- X
- X if (l == 0xb3) /* vertical single bars */
- X {
- X if (t == 0xcd)
- X {tl=0xd5;tr=0xb8;bl=0xd4;br=0xbe;}/* horizontal double bars */
- X else
- X {tl=0xda;tr=0xbf;bl=0xc0;br=0xd9;}/* use hor-s vert-s bars */
- X } /* if */
- X
- X for (i = xmin+1;i <= xmax-1;i++)
- X {
- X win->_line[ymin][i] = t | win->_attrs;
- X win->_line[ymax][i] = b | win->_attrs;
- X }
- X for (i = ymin+1;i <= ymax-1;i++)
- X {
- X win->_line[i][xmin] = l | win->_attrs;
- X win->_line[i][xmax] = r | win->_attrs;
- X }
- X win->_line[ymin][xmin] = tl | win->_attrs;
- X win->_line[ymin][xmax] = tr | win->_attrs;
- X win->_line[ymax][xmin] = bl | win->_attrs;
- X win->_line[ymax][xmax] = br | win->_attrs;
- X
- X for (i=ymin; i <= ymax ; i++)
- X {
- X if (win->_minchng[i] == _NO_CHANGE)
- X {
- X win->_minchng[i] = xmin;
- X win->_maxchng[i] = xmax;
- X } /* if */
- X else
- X {
- X win->_minchng[i] = min(win->_minchng[i], xmin);
- X win->_maxchng[i] = max(win->_maxchng[i], xmax);
- X } /* else */
- X } /* for */
- X return(OK);
- X } /* box */
- X
- X/****************************************************************/
- X/* box(win,v,h) draws a box around window window 'win'. 'v' and */
- X/* 'h' are the vertical and horizontal characters to use. */
- X/****************************************************************/
- X
- Xvoid box(win,v,h)
- X WINDOW *win;
- X char v;
- X char h;
- X {
- X wbox(win,0,0,0,0,v,h);
- X } /* box */
- END_OF_boxes.c
- if test 3864 -ne `wc -c <boxes.c`; then
- echo \"boxes.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f chardel.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"chardel.c\"
- else
- echo Extracting - \"chardel.c\"
- sed "s/^X//" >chardel.c <<'END_OF_chardel.c'
- X/****************************************************************/
- X/* Wdelch() routine of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_chardel_rcsid[] = "@(#)chardel.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wdelch() deletes the character at the window cursor, and the */
- X/* characters to the right of it are shifted left, inserting a */
- X/* space at the last position of the line. */
- X/****************************************************************/
- X
- Xint wdelch(win)
- X WINDOW *win;
- X {
- X short *temp1;
- X short *temp2;
- X short *end;
- X short y = win->_cury;
- X short x = win->_curx;
- X short maxx = win->_maxx - 1;
- X
- X end = &win->_line[y][maxx];
- X temp1 = &win->_line[y][x];
- X temp2 = temp1 + 1;
- X while (temp1 < end)
- X *temp1++ = *temp2++;
- X *temp1 = ' ' | (win->_attrs & ATR_MSK);
- X win->_maxchng[y] = maxx;
- X if (win->_minchng[y] == _NO_CHANGE || win->_minchng[y] > x)
- X win->_minchng[y] = x;
- X return(OK);
- X } /* wdelch */
- X
- X/****************************************************************/
- X/* Delch() deletes the character at the stdscr cursor, and the */
- X/* characters to the right of it are shifted left, inserting a */
- X/* space at the last position of the line. */
- X/****************************************************************/
- X
- Xint delch()
- X {
- X return(wdelch(stdscr));
- X } /* delch */
- X
- X/****************************************************************/
- X/* Mvdelch() moves the stdscr cursor to a new position, then */
- X/* deletes the character at the stdscr cursor, and the charac- */
- X/* ters to the right of it are shifted left, inserting a space */
- X/* at the last position of the line. */
- X/****************************************************************/
- X
- Xint mvdelch(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(wdelch(stdscr));
- X } /* mvdelch */
- X
- X/****************************************************************/
- X/* Mvwdelch() moves the cursor of window 'win' to a new posi- */
- X/* tion, then deletes the character at the stdscr cursor, and */
- X/* the characters to the right of it are shifted left, inser- */
- X/* ting a space at the last position of the line. */
- X/****************************************************************/
- X
- Xint mvwdelch(win,y,x)
- X WINDOW *win;
- X int y;
- X int x;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X return(wdelch(win));
- X } /* mvwdelch */
- END_OF_chardel.c
- if test 3197 -ne `wc -c <chardel.c`; then
- echo \"chardel.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f clrtobot.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"clrtobot.c\"
- else
- echo Extracting - \"clrtobot.c\"
- sed "s/^X//" >clrtobot.c <<'END_OF_clrtobot.c'
- X/****************************************************************/
- X/* Wclrtobot() routine of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
- X/* 1.1: Renamed clrbot() to clrtobot(). Reported by */
- X/* Eric Roscos: 870907 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_clrtobot_rcsid[] = "@(#)clrtobot.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wclrtobot() fills the right half of the cursor line of */
- X/* window 'win', and all lines below it with blanks. */
- X/****************************************************************/
- X
- Xint wclrtobot(win)
- X WINDOW *win;
- X {
- X short y;
- X short minx;
- X static short startx;
- X static short *ptr;
- X static short *end;
- X static short *maxx;
- X static short blank;
- X
- X blank = ' ' | (win->_attrs & ATR_MSK);
- X startx = win->_curx;
- X for (y = win->_cury; y <= win->_regbottom; y++)
- X {
- X minx = _NO_CHANGE;
- X end = &win->_line[y][win->_maxx - 1];
- X for (ptr = &win->_line[y][startx]; ptr <= end; ptr++)
- X {
- X if (*ptr != blank)
- X {
- X maxx = ptr;
- X if (minx == _NO_CHANGE)
- X minx = (int) (ptr - win->_line[y]);
- X *ptr = blank;
- X } /* if */
- X } /* for */
- X if (minx != _NO_CHANGE)
- X {
- X if ((win->_minchng[y] > minx) || (win->_minchng[y] == _NO_CHANGE))
- X win->_minchng[y] = minx;
- X if (win->_maxchng[y] < (int) (maxx - win->_line[y]))
- X win->_maxchng[y] = (int) (maxx - win->_line[y]);
- X } /* if */
- X startx = 0;
- X } /* for */
- X return(OK);
- X } /* wclrtobot */
- X
- X/****************************************************************/
- X/* Clrtobot() fills the right half of the cursor line of */
- X/* stdscr, and all lines below it with blanks. */
- X/****************************************************************/
- X
- Xint clrtobot()
- X {
- X return(wclrtobot(stdscr));
- X } /* clrtobot */
- X
- X/****************************************************************/
- X/* Mvclrtobot() moves the cursor to a new position in stdscr */
- X/* and fills the right half of the cursor line, and all lines */
- X/* below it with blanks. */
- X/****************************************************************/
- X
- Xint mvclrtobot(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(wclrtobot(stdscr));
- X } /* mvclrtobot */
- X
- X/****************************************************************/
- X/* Mvwclrtobot() moves the cursor to a new position in window */
- X/* 'win', and fills the right half of the cursor line, and all */
- X/* lines below it with blanks. */
- X/****************************************************************/
- X
- Xint mvwclrtobot(win,y,x)
- X WINDOW *win;
- X int y;
- X int x;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X return(wclrtobot(win));
- X } /* mvwclrtobot */
- END_OF_clrtobot.c
- if test 3457 -ne `wc -c <clrtobot.c`; then
- echo \"clrtobot.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f clrtoeol.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"clrtoeol.c\"
- else
- echo Extracting - \"clrtoeol.c\"
- sed "s/^X//" >clrtoeol.c <<'END_OF_clrtoeol.c'
- X/****************************************************************/
- X/* Wclrtoeol() routine of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements, misspelled name of mvcrltoeol(): 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 880210 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_clrtoeol_rcsid[] = "@(#)clrtoeol.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wclrtoeol() fills the half of the cursor line to the right */
- X/* of the cursor in window 'win' with blanks. */
- X/****************************************************************/
- X
- Xint wclrtoeol(win)
- X WINDOW *win;
- X {
- X short *maxx;
- X short *ptr;
- X short *end;
- X static short y;
- X static short x;
- X static short minx;
- X static short blank;
- X
- X y = win->_cury;
- X x = win->_curx;
- X blank = ' ' | (win->_attrs & ATR_MSK);
- X
- X end = &win->_line[y][win->_maxx - 1];
- X minx = _NO_CHANGE;
- X maxx = &win->_line[y][x];
- X for (ptr = maxx; ptr <= end; ptr++)
- X {
- X if (*ptr != blank)
- X {
- X maxx = ptr;
- X if (minx == _NO_CHANGE)
- X minx = (int) (ptr - win->_line[y]);
- X *ptr = blank;
- X } /* if */
- X } /* for */
- X
- X if (minx != _NO_CHANGE)
- X {
- X if ((win->_minchng[y] > minx) || (win->_minchng[y] == _NO_CHANGE))
- X win->_minchng[y] = minx;
- X if (win->_maxchng[y] < (int) (maxx - win->_line[y]))
- X win->_maxchng[y] = (int) (maxx - win->_line[y]);
- X } /* if */
- X return(OK);
- X } /* wclrtoeol */
- X
- X/****************************************************************/
- X/* Clrtoeol() fills the half of the cursor line to the right */
- X/* of the cursor in stdscr with blanks. */
- X/****************************************************************/
- X
- Xint clrtoeol()
- X {
- X return(wclrtoeol(stdscr));
- X } /* clrtoeol */
- X
- X/****************************************************************/
- X/* Mvclrtoeol() moves the cursor to a new position in stdscr */
- X/* and fills the right half of the cursor line with blanks. */
- X/****************************************************************/
- X
- Xint mvclrtoeol(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(wclrtoeol(stdscr));
- X } /* mvclrtoeol */
- X
- X/****************************************************************/
- X/* Mvwclrtoeol() moves the cursor to a new position in window */
- X/* 'win', and fills the right half of the cursor line with */
- X/* blanks. */
- X/****************************************************************/
- X
- Xint mvwclrtoeol(win,y,x)
- X WINDOW *win;
- X int y;
- X int x;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X return(wclrtoeol(win));
- X } /* mvwclrtoeol */
- END_OF_clrtoeol.c
- if test 3276 -ne `wc -c <clrtoeol.c`; then
- echo \"clrtoeol.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f curspriv.h -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"curspriv.h\"
- else
- echo Extracting - \"curspriv.h\"
- sed "s/^X//" >curspriv.h <<'END_OF_curspriv.h'
- X/****************************************************************/
- X/* CURSPRIV.H */
- X/* Header file for definitions and declarations for the */
- X/* PCcurses package. These definitions should not be gene- */
- X/* rally accessible to programmers. */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: ERR/ OK redefinied in curses.h. Use of short */
- X/* wherever possible Portability improvements: 900114 */
- X/* 1.3: All modules lint-checked with MSC '-W3' and */
- X/* Turbo'C' '-w -w-pro' switches: 881005 */
- X/* 1.2: Support (by #ifdef UCMASM) for uppercase-only */
- X/* assembly routine names. If UCMASM if defined, */
- X/* all assembler names are #defined as upper case. */
- X/* Not needed if you do "MASM /MX. Also missing */
- X/* declaration of cursesscroll(). Fixes thanks to */
- X/* N.D. Pentcheff: 881002 */
- X/* 1.1: Add _chadd() for raw output routines: 880306 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#define CURSES_RCS_ID "@(#)PCcurses v.1.4 - 900114"
- X
- X/* window properties */
- X
- X#define _SUBWIN 1 /* window is a subwindow */
- X#define _ENDLINE 2 /* last winline is last screen line */
- X#define _FULLWIN 4 /* window fills screen */
- X#define _SCROLLWIN 8 /* window lwr rgt is screen lwr rgt */
- X
- X/* Miscellaneous */
- X
- X#define _INBUFSIZ 200 /* size of terminal input buffer */
- X#define _NO_CHANGE -1 /* flags line edge unchanged */
- X
- X#define _BREAKCHAR 0x03 /* ^C character */
- X#define _DCCHAR 0x08 /* Delete Char char (BS) */
- X#define _DLCHAR 0x1b /* Delete Line char (ESC) */
- X#define _GOCHAR 0x11 /* ^Q character */
- X#define _PRINTCHAR 0x10 /* ^P character */
- X#define _STOPCHAR 0x13 /* ^S character */
- X#define NUNGETCH 10 /* max # chars to ungetch() */
- X
- X/* character mask definitions */
- X
- X#define CHR_MSK ((int) 0x00ff) /* ASCIIZ character mask */
- X#define ATR_MSK ((int) 0xff00) /* attribute mask */
- X#define ATR_NRM ((int) 0x0000) /* no special attributes */
- X
- X/* type declarations */
- X
- Xtypedef struct
- X {
- X WINDOW *tmpwin; /* window used for updates */
- X short cursrow; /* position of physical cursor */
- X short curscol;
- X bool autocr; /* if lf -> crlf */
- X bool cbreak; /* if terminal unbuffered */
- X bool echo; /* if terminal echo */
- X bool raw; /* if terminal raw mode */
- X bool refrbrk; /* if premature refresh brk allowed */
- X bool orgcbr; /* original MSDOS ^-BREAK setting */
- X } cursv;
- X
- X/* External variables */
- X
- Xextern cursv _cursvar; /* curses variables */
- X
- X/* 'C' standard library function declarations */
- X
- Xextern char *calloc();
- Xextern char *malloc();
- Xextern void free();
- Xextern int sprintf();
- Xextern int sscanf();
- X
- X/* Curses internal functions, not to be used by programmers */
- X
- X/* #Define UCMASM if your version of MASM does not support */
- X/* the '/MX' switch, or if you use another assembler */
- X
- X#ifdef UCMASM
- X#define _cursescattr _CURSESCATTR
- X#define _cursescmode _CURSESCMODE
- X#define _cursescursor _CURSESCURSOR
- X#define _cursesgcb _CURSESGCB
- X#define _cursesgcmode _CURSESGCMODE
- X#define _cursesgcols _CURSESGCOLS
- X#define _curseskey _CURSESKEY
- X#define _cursesscroll _CURSESSCROLL
- X#define _curseskeytst _CURSESKEYTST
- X#define _cursesputc _CURSESPUTC
- X#define _cursesscb _CURSESSCB
- X#endif
- X
- Xextern int _chadd();
- Xextern void _cursescattr();
- Xextern void _cursescmode();
- Xextern void _cursescursor();
- Xextern int _cursesgcb();
- Xextern int _cursesgcmode();
- Xextern int _cursesgcols();
- Xextern int _curseskey();
- Xextern bool _curseskeytst();
- Xextern void _cursesscroll();
- Xextern bool _cursespendch();
- Xextern void _cursesputc();
- Xextern void _cursesscb();
- END_OF_curspriv.h
- if test 3995 -ne `wc -c <curspriv.h`; then
- echo \"curspriv.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f linedel.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"linedel.c\"
- else
- echo Extracting - \"linedel.c\"
- sed "s/^X//" >linedel.c <<'END_OF_linedel.c'
- X/****************************************************************/
- X/* Wdeleteln() routine of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_linedel_rcsid[] = "@(#)linedel.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wdeleteln() deletes the line at the window cursor, and the */
- X/* lines below it are shifted up, inserting a blank line at */
- X/* the bottom of the window. */
- X/****************************************************************/
- X
- Xint wdeleteln(win)
- X WINDOW *win;
- X {
- X short *end;
- X short *temp;
- X short y;
- X static short blank;
- X
- X blank = ' ' | (win->_attrs & ATR_MSK);
- X
- X temp = win->_line[win->_cury];
- X for (y = win->_cury; y < win->_regbottom; y++)
- X {
- X win->_line[y] = win->_line[y+1];
- X win->_minchng[y] = 0;
- X win->_maxchng[y] = win->_maxx - 1;
- X }
- X win->_minchng[y] = 0;
- X win->_maxchng[y] = win->_maxx - 1;
- X win->_line[win->_regbottom] = temp;
- X for (end = &(temp[win->_maxx -1]); temp <= end;)
- X *temp++ = blank;
- X return(OK);
- X } /* wdeleteln */
- X
- X/****************************************************************/
- X/* Deleteln() deletes the line at the stdscr cursor, and the */
- X/* lines below it are shifted up, inserting a blank line at */
- X/* the bottom of stdscr. */
- X/****************************************************************/
- X
- Xint deleteln()
- X {
- X return(wdeleteln(stdscr));
- X } /* deleteln */
- X
- X/****************************************************************/
- X/* Mvdeleteln() moves the cursor to a new position in stdscr, */
- X/* then deletes the line at the window cursor, and the lines */
- X/* below it are shifted up, inserting a blank line at the bot- */
- X/* tom of stdscr. */
- X/****************************************************************/
- X
- Xint mvdeleteln(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(wdeleteln(stdscr));
- X } /* mvdeleteln */
- X
- X/****************************************************************/
- X/* Mvwdeleteln() moves the cursor to a new position in a win- */
- X/* dow, then deletes the line at the window cursor, and the */
- X/* lines below it are shifted up, inserting a blank line at */
- X/* the bottom of the window. */
- X/****************************************************************/
- X
- Xint mvwdeleteln(win,y,x)
- X WINDOW *win;
- X int y;
- X int x;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X return(wdeleteln(win));
- X } /* mvwdeleteln */
- END_OF_linedel.c
- if test 3229 -ne `wc -c <linedel.c`; then
- echo \"linedel.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f lineins.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"lineins.c\"
- else
- echo Extracting - \"lineins.c\"
- sed "s/^X//" >lineins.c <<'END_OF_lineins.c'
- X/****************************************************************/
- X/* Winsertln() routine of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
- X/* 1.1: Mvinsertln() and friends were misrenamed: 880305 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_lineins_rcsid[] = "@(#)lineins.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Winsertln() inserts a blank line instead of the cursor line */
- X/* in window 'win' and pushes other lines down. */
- X/****************************************************************/
- X
- Xint winsertln(win)
- X WINDOW *win;
- X {
- X short *temp;
- X short *end;
- X short y;
- X static short blank;
- X
- X blank = ' ' | (win->_attrs & ATR_MSK);
- X temp = win->_line[win->_regbottom];
- X for (y = win->_regbottom; y > win->_cury; y--)
- X {
- X win->_line[y] = win->_line[y-1];
- X win->_minchng[y] = 0;
- X win->_maxchng[y] = win->_maxx - 1;
- X } /* for */
- X win->_line[win->_cury] = temp;
- X for (end = &temp[win->_maxx -1]; temp <= end; temp++)
- X *temp = blank;
- X win->_minchng[win->_cury] = 0;
- X win->_maxchng[win->_cury] = win->_maxx - 1;
- X return(OK);
- X } /* winsertln */
- X
- X/****************************************************************/
- X/* Insertln() inserts a blank line instead of the cursor line */
- X/* in stdscr and pushes other lines down. */
- X/****************************************************************/
- X
- Xint insertln()
- X {
- X return(winsertln(stdscr));
- X } /* insertln */
- X
- X/****************************************************************/
- X/* Mvinsertln() moves the stdscr cursor to a new positions, in- */
- X/* serts a blank line instead of the cursor line and pushes */
- X/* other lines down. */
- X/****************************************************************/
- X
- Xint mvinsertln(y,x)
- X int y;
- X int x;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X return(winsertln(stdscr));
- X } /* mvinsertln */
- X
- X/****************************************************************/
- X/* Mvwinsertln() moves the cursor in window 'win' to a new po- */
- X/* si tions, inserts a blank line instead of the cursor line */
- X/* and pushes other lines down. */
- X/****************************************************************/
- X
- Xint mvwinsertln(win,y,x)
- X WINDOW *win;
- X int y;
- X int x;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X return(winsertln(win));
- X } /* mvwinsertln */
- END_OF_lineins.c
- if test 3103 -ne `wc -c <lineins.c`; then
- echo \"lineins.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f options.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"options.c\"
- else
- echo Extracting - \"options.c\"
- sed "s/^X//" >options.c <<'END_OF_options.c'
- X/****************************************************************/
- X/* Idlok(), clearok(), leaveok(), scrollok(), nodelay(), key- */
- X/* pad(), meta(), cursoff() and curson() routines of the */
- X/* PCcurses package. */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Rcsid[] string for maintenance: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_options_rcsid[] = "@(#)option.c v.1.4 - 900114";
- X
- Xstatic bool hasold = FALSE; /* for remembering old cursor type */
- Xstatic int oldmode;
- X
- X/****************************************************************/
- X/* Idlok() is used to set flag for using the terminal insert/ */
- X/* delete line capabilities. This is not relevant for the PC */
- X/* version of curses, and thus nothing is done. */
- X/****************************************************************/
- X
- Xvoid idlok()
- X {
- X } /* idlok */
- X
- X/****************************************************************/
- X/* Clearok() marks window 'win' to cause screen clearing and */
- X/* redraw the next time a refresh is done. */
- X/****************************************************************/
- X
- Xvoid clearok(win, flag)
- X WINDOW *win;
- X bool flag;
- X {
- X if (win == curscr)
- X _cursvar.tmpwin->_clear = flag;
- X else
- X win->_clear = flag;
- X } /* clearok */
- X
- X/****************************************************************/
- X/* Leaveok() marks window 'win' to allow the update routines */
- X/* to leave the hardware cursor where it happens to be at the */
- X/* end of update. Usually used in combination with cursoff(). */
- X/****************************************************************/
- X
- Xvoid leaveok(win, flag)
- X WINDOW *win;
- X bool flag;
- X {
- X win->_leave = flag;
- X } /* leaveok */
- X
- X/****************************************************************/
- X/* Scrollok() marks window 'win' to allow the scrolling region */
- X/* of it to actually scroll. */
- X/****************************************************************/
- X
- Xvoid scrollok(win, flag)
- X WINDOW *win;
- X bool flag;
- X {
- X win->_scroll = flag;
- X } /* scrollok */
- X
- X/****************************************************************/
- X/* Nodelay() marks the window to make character input non- */
- X/* waiting, i.e. if there is no character to get, -1 will be */
- X/* returned. */
- X/****************************************************************/
- X
- Xvoid nodelay(win, flag)
- X WINDOW *win;
- X bool flag;
- X {
- X win->_nodelay = flag;
- X } /* nodelay */
- X
- X/****************************************************************/
- X/* Keypad() marks window 'win' to use the special keypad mode. */
- X/****************************************************************/
- X
- Xvoid keypad(win, flag)
- X WINDOW *win;
- X bool flag;
- X {
- X win->_keypad = flag;
- X } /* keypad */
- X
- X/****************************************************************/
- X/* Meta() allows use of any alternate character set allowed by */
- X/* the terminal. We always allow this on the PC, so this one */
- X/* does nothing. */
- X/****************************************************************/
- X
- Xvoid meta()
- X {
- X } /* meta */
- X
- X/****************************************************************/
- X/* Cursoff() turns off the hardware cursor. */
- X/****************************************************************/
- X
- Xvoid cursoff()
- X {
- X if (!hasold)
- X {
- X oldmode = _cursesgcmode(); /* get old cursor type */
- X hasold = TRUE;
- X }
- X _cursescmode(31,30); /* turn it off */
- X } /* cursoff */
- X
- X/****************************************************************/
- X/* Curson() turns on the hardware cursor. */
- X/****************************************************************/
- X
- Xvoid curson()
- X {
- X if (hasold)
- X {
- X _cursescmode(oldmode >> 8,oldmode);
- X hasold = FALSE;
- X }
- X } /* curson */
- END_OF_options.c
- if test 4376 -ne `wc -c <options.c`; then
- echo \"options.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f refresh.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"refresh.c\"
- else
- echo Extracting - \"refresh.c\"
- sed "s/^X//" >refresh.c <<'END_OF_refresh.c'
- X/****************************************************************/
- X/* Wrefresh() and wnoutrefresh() routines of the PCcurses */
- X/* package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Refresh() slig- */
- X/* htly faster. Portability improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Max limits off by 1. Fixed thanks to S. Creps: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_refresh_rcsid[] = "@(#)refresh.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Wrefresh() updates window win's area of the physical screen. */
- X/****************************************************************/
- X
- Xvoid wrefresh(win)
- X WINDOW *win;
- X {
- X if (win == curscr)
- X curscr->_clear = TRUE;
- X else
- X wnoutrefresh(win);
- X doupdate();
- X } /* wrefresh */
- X
- X/****************************************************************/
- X/* Wnoutrefresh() updates the image of the desired screen, */
- X/* without doing physical update (copies window win's image to */
- X/* the _cursvar.tmpwin window, which is hidden from the user). */
- X/****************************************************************/
- X
- Xvoid wnoutrefresh(win)
- X register WINDOW *win;
- X {
- X register short *dst; /* start destination in temp window */
- X register short *end; /* end destination in temp window */
- X register short *src; /* source in user window */
- X register short first; /* first changed char on line */
- X register short last; /* last changed char on line */
- X static WINDOW *nscr;
- X static short begy; /* window's place on screen */
- X static short begx;
- X static short i;
- X static short j;
- X
- X nscr = _cursvar.tmpwin;
- X begy = win->_begy;
- X begx = win->_begx;
- X
- X for (i=0, j=begy; i < win->_maxy; i++, j++)
- X {
- X if (win->_minchng[i] != _NO_CHANGE)
- X {
- X first = win->_minchng[i];
- X last = win->_maxchng[i];
- X dst = &(nscr->_line[j][begx + first]);
- X end = &(nscr->_line[j][begx + last]);
- X src = &(win->_line[i][first]);
- X
- X while (dst <= end) /* copy user line to temp window */
- X *dst++ = *src++;
- X
- X first += begx; /* nscr's min/max change positions */
- X last += begx;
- X
- X if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first))
- X nscr->_minchng[j] = first;
- X if (last > nscr->_maxchng[j])
- X nscr->_maxchng[j] = last;
- X
- X win->_minchng[i] = _NO_CHANGE; /* updated now */
- X } /* if */
- X win->_maxchng[i] = _NO_CHANGE; /* updated now */
- X } /* for */
- X
- X if (win->_clear)
- X {
- X win->_clear = FALSE;
- X nscr->_clear = TRUE;
- X } /* if */
- X
- X if (!win->_leave)
- X {
- X nscr->_cury = win->_cury + begy;
- X nscr->_curx = win->_curx + begx;
- X } /* if */
- X } /* wnoutrefresh */
- X
- X/****************************************************************/
- X/* Refresh() updates stdscr's area of the physical screen. */
- X/****************************************************************/
- X
- Xvoid refresh()
- X {
- X wnoutrefresh(stdscr);
- X doupdate();
- X } /* refresh */
- END_OF_refresh.c
- if test 3577 -ne `wc -c <refresh.c`; then
- echo \"refresh.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f setmode.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"setmode.c\"
- else
- echo Extracting - \"setmode.c\"
- sed "s/^X//" >setmode.c <<'END_OF_setmode.c'
- X/****************************************************************/
- X/* Terminal mode routines of the PCcurses package. */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* BUT: this particualr module was written by */
- X/* N. Dean Pentcheff (dean@violet.berkeley.edu) */
- X/* It provides PC Curses versions of: */
- X/* reset_prog_mode(); */
- X/* reset_shell_mode(); */
- X/* set_prog_mode(); */
- X/* set_shell_mode(); */
- X/* */
- X/* B. Larsson took the liberty to mofify it's style slightly */
- X/* when incorporating it into PCcurses v.1.2. The routines in */
- X/* this module do a similar thing to savetty() and resetty(). */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Style clean-up, rcsid[] string for main- */
- X/* tenance: 881002 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xstruct cttyset
- X {
- X bool been_set;
- X bool oautocr;
- X bool ocbreak;
- X bool oecho;
- X bool oraw;
- X };
- X
- Xchar _curses_setmode_rcsid[] = "@(#)setmode.c v.1.4 - 900114";
- X
- Xstatic struct cttyset pr_tty = {FALSE};/* tty modes for prog_mode */
- X
- X/****************************************************************/
- X/* Def_prog_mode() saves the current tty status, to be recalled */
- X/* later by reset_prog_mode. */
- X/****************************************************************/
- X
- Xvoid def_prog_mode()
- X {
- X pr_tty.been_set = TRUE;
- X pr_tty.oautocr = _cursvar.autocr;
- X pr_tty.ocbreak = _cursvar.cbreak;
- X pr_tty.oecho = _cursvar.echo;
- X pr_tty.oraw = _cursvar.raw;
- X } /* def_prog_mode */
- X
- X/****************************************************************/
- X/* Reset_prog_mode() resets tty modes to the values saved in a */
- X/* call to def_prog_mode. */
- X/****************************************************************/
- X
- Xvoid reset_prog_mode()
- X {
- X if (pr_tty.been_set == TRUE)
- X {
- X _cursvar.autocr = pr_tty.oautocr;
- X _cursvar.cbreak = pr_tty.ocbreak;
- X _cursvar.echo = pr_tty.oecho;
- X _cursvar.raw = pr_tty.oraw;
- X } /* if */
- X } /* reset_prog_mode */
- X
- X/****************************************************************/
- X/* Def_shell_mode() saves the tty status, to be recalled by */
- X/* reset_shell_mode. A noop in PCcurses. */
- X/****************************************************************/
- X
- Xvoid def_shell_mode()
- X {
- X } /* def_shell_mode */
- X
- X/****************************************************************/
- X/* Reset_shell_mode() resets the tty status to the status it */
- X/* had before curses began. */
- X/****************************************************************/
- X
- Xvoid reset_shell_mode()
- X {
- X _cursvar.autocr = TRUE;
- X _cursvar.cbreak = FALSE;
- X _cursvar.echo = TRUE;
- X _cursvar.raw = FALSE;
- X } /* reset_shell_mode */
- END_OF_setmode.c
- if test 3300 -ne `wc -c <setmode.c`; then
- echo \"setmode.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f setterm.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"setterm.c\"
- else
- echo Extracting - \"setterm.c\"
- sed "s/^X//" >setterm.c <<'END_OF_setterm.c'
- X/****************************************************************/
- X/* Raw(), noraw(), echo(), noecho(), nl(), nonl(), cbreak(), */
- X/* nocbreak(), crmode(), nocrmode() and refrbrk() routines of */
- X/* the PCcurses package. */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Rcsid[] string for maintenance: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_setterm_rcsid[] = "@(#)setterm.c v.1.4 - 900114";
- X
- X/****************************************************************/
- X/* Raw() and noraw() sets or clears raw mode. */
- X/****************************************************************/
- X
- Xvoid raw()
- X {
- X _cursvar.raw = TRUE;
- X _cursesscb(FALSE); /* disallow ^BREAK on disk I/O */
- X flushinp();
- X } /* raw */
- X
- Xvoid noraw()
- X {
- X _cursvar.raw = FALSE;
- X _cursesscb(_cursvar.orgcbr); /* restore original ^BREAK status */
- X } /* noraw */
- X
- X/****************************************************************/
- X/* Echo() and noecho() sets or clears echo mode. */
- X/****************************************************************/
- X
- Xvoid echo()
- X {
- X _cursvar.echo = TRUE;
- X } /* echo */
- X
- Xvoid noecho()
- X {
- X _cursvar.echo = FALSE;
- X } /* noecho */
- X
- X/****************************************************************/
- X/* Nl() and nonl() sets or clears autocr mapping mode. */
- X/****************************************************************/
- X
- Xvoid nl()
- X {
- X _cursvar.autocr = TRUE;
- X } /* nl */
- X
- Xvoid nonl()
- X {
- X _cursvar.autocr = FALSE;
- X } /* nonl */
- X
- X/****************************************************************/
- X/* Cbreak(), nocbreak(), crmode() amd nocrmode() sets or */
- X/* clears cbreak mode. */
- X/****************************************************************/
- X
- Xvoid cbreak()
- X {
- X _cursvar.cbreak = TRUE;
- X } /* cbreak */
- X
- Xvoid nocbreak()
- X {
- X _cursvar.cbreak = FALSE;
- X } /* nocbreak */
- X
- Xvoid crmode()
- X {
- X _cursvar.cbreak = TRUE;
- X } /* crmode */
- X
- Xvoid nocrmode()
- X {
- X _cursvar.cbreak = FALSE;
- X } /* nocrmode */
- X
- X/****************************************************************/
- X/* Refrbrk() sets or unsets the screen refresh break flag. If */
- X/* this flag is set, and there is any input available, any */
- X/* screen refresh will be prematurely terminated, anticipating */
- X/* more screen updates. This flag is FALSE by default. */
- X/****************************************************************/
- X
- Xvoid refrbrk(bf)
- X bool bf;
- X {
- X _cursvar.refrbrk = bf;
- X } /* refrbrk */
- END_OF_setterm.c
- if test 3094 -ne `wc -c <setterm.c`; then
- echo \"setterm.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo End of archive 2 \(of 7\).
- cp /dev/null archdone.2
- MISSING=""
- for I in 1 2 3 4 5 6 7 ; do
- if test ! -f archdone.${I} ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 7 archives.
- rm -f archdone.[1-9]
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-